Learn R Programming

shinyBS (version 0.20)

Table Highlighting: Table Highlighting

Description

Functions to style table elements based on their contents.

Usage

highlightRows(session, id, column, min = NULL, max = NULL, regex = NULL, 
              class = NULL, style = NULL, reset = NULL)
highlightCells(session, id, min = NULL, max = NULL, regex = NULL, class = NULL, 
               style = NULL, reset = NULL, skip.row.names = TRUE)

Arguments

session
The session object passed to function given to shinyServer
id
The id of the table you want to highlight
column
For highlightRows the column to do matching on
min
The minimum value of a cell that will match (inclusive)
max
The maximum value of a cell that will match (inclusive)
regex
A regular expression to base the match on.
class
The name of the class to apply to matches
style
CSS style attributes to apply to matches
reset
Should preexisting styles be removed?
skip.row.names
Should the first column of the table be ignored because it contains row names?

Details

highlightCells() is used for highlighting individual cells and highlightRows() is used for highlighting entire rows. Both functions use the same arguments with highlightRows() having an additional column argument for indicating the column to search. You can supply the column argument with the value that appears in the top row or with a numeric index value for the column. Cells can be styled with the class or style arguments. class can be one of eight predefined classes (success, warning, error, info, good, bad, neutral, disabled) or any class you have defined. If you use the style argument its contents will be directly inserted into the style attribute of matching td and tr elements.

References

http://getbootstrap.com/2.3.2/base-css.html{Tables for Twitter Bootstrap 2.3.2}

Examples

Run this code
# Apply the 'warning' class to cells in table 'htTable' that contain a value 
  # between 5 and 10
  highlightCells(session, 'htTable', class = "warning", min = 5, max = 10)
  
  # Apply the 'info' class to rows in table 'htTable' where the text in the 
  # first column contains an 'i'.
  highlightRows(session, 'htable', column = NULL, class = "info", regex = "i")

Run the code above in your browser using DataLab